﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.DesignScript.Geometry;

namespace DeepSpace.Analysis
{
    public class SolarAnalysis
    {
        const int RAY_LENGTH = 1000000;

        public IList<int> GetSolarExposureValue(IList<Point> points, IList<Vector> solarVectors, Geometry geometry)
        {
            var exposureValues = new int[points.Count];

            for (int i = 0; i < points.Count(); ++i)
            {
                var point = points[i];

                var value = 0;
                foreach (var vec in solarVectors)
                {
                    var ray = Line.ByStartPointDirectionLength(point, vec, RAY_LENGTH);
                    if (!ray.DoesIntersect(geometry))
                    {
                        value = value + 1;
                    }
                }

                exposureValues[i] = value;
            }

            return exposureValues;
        }
    }
}
